﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 小区物业管理系统
{
    public partial class 登录 : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
           小区物业管理系统DataContext db = new 小区物业管理系统DataContext();
            if (RadioButtonList1.SelectedValue == "用户")
            {
                var result = (from r in db.用户信息
                              where r.用户姓名 == TextBox1.Text && r.密码 == TextBox2.Text
                              select r).FirstOrDefault();
                if (result == null)
                {
                    Label3.Text = "用户不存在，请先注册！";
                }
                else
                {
                  
                    Response.Redirect("~/首页.aspx");
                }
            }
            else if (RadioButtonList1.SelectedValue == "管理员")
            {
                var result = (from r in db.管理员
                              where r.编号 == TextBox1.Text && r.密码 == TextBox2.Text
                              select r).FirstOrDefault();
                if (result == null)
                {
                    Label3.Text = "管理员不存在，请先注册！";
                }
                else
                {
                    Response.Redirect("~/小区公告管理.aspx");
                }
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {

        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/注册.aspx");
        }
    }
}